package test;

import org.xmap.ui.View;
import org.xmap.ui.ViewManager;
import org.xmap.ui.base.Window;
import org.xmap.ui.control.Label;

public class LabelView extends View {

    private Label l;

    public LabelView(View back) {
        super(back);
//        this.setBgColor(0xffffff88);
        this.setTitleText("标签控件演示");
        this.l = new Label("这是一个标签", 10, 10, 120, 30, Window.ORIENT_LEFT_UP);
        this.addControls(l);
        this.addLeftMenu("随机标签颜色");
        this.addLeftMenu("随机边框颜色");
        this.addLeftMenu("边框模式", new String[]{"边框显示", "边框隐藏"});
        this.addLeftMenu("对齐方式", new String[]{"左对齐", "居中对齐", "右对齐"});
//        this.addLeftMenu("随机文字偏移");
        this.addLeftMenu("背景模式", new String[]{"背景透明", "背景可见"});
        this.setRightMenu("返回");
    }

    public void update() {
//        this.l.setTextColor((int) System.currentTimeMillis());
    }

    public void commandEvent(String command, Window sender) {
        if (command.equals("随机标签颜色")) {
//            this.l.setTextColor(XmapDemo.getRandomColor());
        } else if (command.equals("随机边框颜色")) {
//            this.l.setLineColor(XmapDemo.getRandomColor());
        } else if (command.equals("边框显示")) {
//            this.l.setDrawRect(true);
        } else if (command.equals("边框隐藏")) {
//            this.l.setDrawRect(false);
        } else if (command.equals("左对齐")) {
//            this.l.setAlign(Window.ALIGN_LEFT);
        } else if (command.equals("居中对齐")) {
//            this.l.setAlign(Window.ALIGN_CENTER);
        } else if (command.equals("右对齐")) {
//            this.l.setAlign(Window.ALIGN_RIGHT);
//        } else if (command.equals("随机文字偏移")) {
//            int offset = Math.abs((int) System.currentTimeMillis()) % this.l.getRect().width;
//            this.l.setOffset(offset);
        } else if (command.equals("背景透明")) {
//            this.l.setTransparent(true);
        } else if (command.equals("背景可见")) {
//            this.l.setTransparent(false);
        } else if (command.equals("返回")) {
            ViewManager.instance.setView(this.back, View.ANIMATION_LEFT_TO_RIGHT);
        }
    }
}
